Documents that include objects such as text, pictures, tables, etc., are becoming more common as a tool for effectively communicating intents and goals. It is oftentimes the case, however, that when a document contains these objects the width of such objects is not predefined in the document properties. An application formatting the document for the purposes of displaying or printing then needs to determine an optimal size (width) of the objects based on the content of such object. The content of an object may be complex and determining the ideal size becomes a non-trivial task. For example, if the object contains some left-aligned text or floater objects and also some right-aligned text or floater objects an algorithm is then employed to layout these objects properly to determine how do the objects fit on the page relative to each other. This problem is commonly known as autofitting objects, or as a “shrink-to-fit” algorithm.
Different applications attempt to solve this problem in different ways. For example, a word processor may use a proprietary algorithm for floaters and tables, while browsers also attempt to solve this problem in yet another way. One emerging standard Cascading Style Sheets (CSS)—a W3C standard for Web (HTML) layout, recognizes this problem as complex, describes some basic requirements for autofitting objects, but leaves the exact algorithm to the developers of applications. Furthermore, there are complex (non-trivial) cases (such as a block width being a percentage of a parent block width and the parent block width is unknown) where CSS does not define requirements to the layout. In such cases the standard indicates that the layout is undefined and gives developers the freedom of coming up with some reasonable layout.